import Vue from 'vue'

// 事件总线
// import App from './testPage/pages'
// 继承
// import App from './testPage/child'
// 插槽传值
// import App from './testPage/slot'
// 观察属性和计算属性
//  import App from './testPage/watchAndComputed'

// 路由
import App from './routerPage'
// 引入路由插件库
import Router from 'vue-router'
// 注册插件
Vue.use(Router)
// 引入页面路由组件
import Login from './routerPage/login'
import Home from './routerPage/home'
import Edit from './routerPage/home/edit'

//因为Router是一个Class，所以需要进行实例化
let router = new Router({
    // 路由配置22222
    routes:[
        // 在系统中都有一个重定向的路由配置
        {path: '/', redirect : '/login'},
        // 路由地址属性--path，路由对应的组件属性--component
        {path: '/login', component: Login},
        {path: '/home', component: Home},
        {path: '/home/edit', component: Edit}
    ]
})


router.beforeEach((to, from, next) => {
    if(to.path === '/login') {
        next()
        return
    }

    let token = sessionStorage.getItem('token')
    if(!token) {
        if(from.path === '/login') {

        }else {
            next('./login')
        }
    }else {
        next()
    }
})

 var c = [1, 432, 43, 78, 826, 367, 6732]
 console.log(c.filter(it => it > 100))
 var d = c.reduce(function(newArr, item) {
     if (item > 100) newArr.push(item)
     return newArr
 }, [])
 console.log(d)

 

new Vue({
    router: router,
    // data(){
    //     return {
    //         eventBus: new Vue()
    //     }
    // },
    render: ce => ce(App)
}).$mount('#root')
